package socketmvc.server.config;

import socketmvc.core.codec.IPacketCodec;
import socketmvc.core.codec.ProtocolCodecHandler;
import socketmvc.core.config.SocketMvcConfig;
import socketmvc.core.filter.FilterHandler;
import socketmvc.core.filter.IFilter;
import socketmvc.core.processor.ProcessorMethodHandler;

import java.util.Collection;
import java.util.Set;

public class SingleSocketMvcConfig implements SocketMvcConfig {

    protected SocketMvcConfig targetMvcConfig;

    private final IpConfig targetIpConfig;


    public SingleSocketMvcConfig(SocketMvcConfig targetMvcConfig, IpConfig targetIpConfig) {
        this.targetMvcConfig = targetMvcConfig;
        this.targetIpConfig = targetIpConfig;
    }

    @Override
    public IpConfig getIpConfig() {
        return targetIpConfig;
    }

    /**
     * 获取扫描处理器的包路径
     *
     * @return 包路径
     */
    @Override
    public Set<String> getProcessorScanPackage() {
        return targetMvcConfig.getProcessorScanPackage();
    }

    /**
     * 获取过滤器
     *
     * @return Filters
     */
    @Override
    public Collection<IFilter> getFilters() {
        return targetMvcConfig.getFilters();
    }

    /**
     * 获取数据包编解码器
     *
     * @return Codecs
     */
    @Override
    public Collection<IPacketCodec> getPacketCodecs() {
        return targetMvcConfig.getPacketCodecs();
    }

    /**
     * 获取mvc方法映射处理器(处理类方法和注解的mvc路径的对应关系以及其参数类型映射等等)
     *
     * @return ProcessorMethodHandler
     */
    @Override
    public ProcessorMethodHandler getProcessorMethodHandler() {
        return targetMvcConfig.getProcessorMethodHandler();
    }

    /**
     * 获取报文的协议编解码器
     *
     * @return ProtocolCodecHandler
     */
    @Override
    public ProtocolCodecHandler getProtocolCodecHandler() {
        return targetMvcConfig.getProtocolCodecHandler();
    }

    /**
     * 获取mvc过滤器
     *
     * @return ProtocolCodecHandler
     */
    @Override
    public FilterHandler getFilterHandler() {
        return targetMvcConfig.getFilterHandler();
    }
}
